package leetcode;

/**
 * @program: datastructureandalogorithm
 * @description:
 * @author: hmx
 * @create: 2021-12-18 13:23
 **/
public class LeetCode419 {

    //统计起点
    public int countBattleships(char[][] board) {
        int m = board.length;
        int n = board[0].length;
        //战舰或者战舰群的数量
        int count = 0;

        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                if (board[i][j] == 'X' && (i == 0 || board[i - 1][j] != 'X') && (j == 0 || board[i][j - 1] != 'X')) {
                    count++;
                }
            }
        }

        return count;
    }

}
